package com.qut.system_1.controller;

import com.qut.system_1.util.EmailUtil;
import com.qut.system_1.mapper.UserMapper;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/user")

public class UserController {
    @Resource
private UserMapper userMapper;
    @RequestMapping("/reg")
    public int reg(@RequestParam Map<String,String> param){
        int row=0;
      row=userMapper.save(param);
        System.out.println(param);
        return row;
    }
   @RequestMapping("/search")
   public List<Map<String,Object>> search(@RequestParam Map<String,String> param){
       List<Map<String,Object>> list=null;
        list=userMapper.search(param);
       return list;
   }
    @RequestMapping("/search1")
    public List<Map<String,Object>> search1(@RequestParam Map<String,String> param){
        List<Map<String,Object>> list=null;
        list=userMapper.search1(param);
        return list;
    }
    //增加记录



@RequestMapping("/delete")
public  int batchDelete(String[] ids){
    int row=0;
    row=userMapper.batchDelete(ids);
    return row;
}
@RequestMapping("/edit")
public int edit(@RequestParam Map<String,String> param){
    int row=0;
    row=userMapper.update(param);
//    System.out.println(param);
    return row;


}
    @Resource
private EmailUtil emailUtil;
    @RequestMapping("/email")
    public int email(@RequestParam Map<String,String> param){
        System.out.println(param);
        int row=0;
        row=emailUtil.sendMail(param.get("userEmail"));
        return row;
    }

}
